<?php
session_start(); // Initialize Session data
//session_name();
ob_start(); // Turn on output buffering
//ob_start("ob_gzhandler");

//phpinfo();


//calculating execution time
$mtime = microtime();
$mtime = explode(" ",$mtime);
$mtime = $mtime[1] + $mtime[0];
$starttime = $mtime;

include "butterflyportal/ewcfg7.php";
include "butterflyportal/ewmysql7.php";
include "butterflyportal/phpfn7.php";
include "userfn.php";

//echo $_SERVER['HTTP_HOST'];
if (false) {
    echo("<pre>\n");
    print_r($_REQUEST);
    echo("</pre>\n");
    exit();
}

error_reporting(E_ALL);
if (isLocal()) ini_set('display_errors', '1'); else ini_set('display_errors', '0');
//include "portal/portal_loginsinfo.php";



header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
header("Connection: Keep-Alive");
header("Keep-Alive: timeout=300");

$debug=getParameter("debug");

//header('Content-Type:text/html; charset=UTF-8');
global $conn, $Language, $international, $agencyId, $defaultCountry, $defaultCity,$currentUserLevel,$portalId,$mode, $pagetitle, $FB_description, $FB_image;


// Open connection
$conn = ew_Connect();



//Language and direction

$portalId=getPortalId();
$_REQUEST["portalId"]=$portalId;



//Get applications variables.

getPortalAppVars();
// User profile
$UserProfile = new cUserProfile();
$UserProfile->LoadProfile(@$_SESSION[EW_SESSION_USER_PROFILE]);



// Security
$Security = new cAdvancedSecurity();


// Language object
$Language = new cLanguage();
$GLOBALS["gsTimer"] = new cTimer();


//$GLOBALS["portal_logins"] = new cportal_logins();

//$agencyId=getAgencyId();

//Facebook Integration initialization

$FB_description="";
$FB_image="";

$show_controls=true;

if (getParameter("nocontrols")=="true") $show_controls=false;


if (isset($portalId) && $portalId!=""){

    if (! isPaid()) {

        Dispaly_Page_Msg("Le service en question n'est pas encore payÃƒÂ© !");

    }else{



        $sSql="SELECT * FROM portal where id= $portalId";
        $rs=$GLOBALS["conn"]->Execute($sSql);



        $keywords=$rs->fields["keywords"];
        $description=$rs->fields["description"];




        if (getParameter("language")!=null)
        {
            $lang=getParameter("language");
            $_SESSION["language"]=$lang;
        }
        else
            if (isset($_SESSION["language"]))
                $lang=$_SESSION["language"];
            else{

                $sSql="Select * From portal_languages Where portal_languages.id = ".$rs->fields["defaultLang"];
                $rslang=$GLOBALS["conn"]->Execute($sSql);
                $lang=$rslang->fields["value"];
            }

        //check if the language is in the portal languages



        $sSql="SELECT portal_languages.`value` FROM portal_languages INNER JOIN portal_portal_languages ON portal_portal_languages.languageId = portal_languages.id WHERE portal_languages.`value`='$lang' and portal_portal_languages.portalId = $portalId";
        $rslang=$GLOBALS["conn"]->Execute($sSql);
        if ($lang!=$rslang->fields["value"]) {
// getting default language
            $sSql="SELECT portal_languages.`value` FROM portal INNER JOIN portal_languages ON portal.defaultLang = portal_languages.id WHERE portal.id = $portalId";

            $rslang=$GLOBALS["conn"]->Execute($sSql);
            $lang=$rslang->fields["value"];
        }


        $LANG=strtoupper($lang);
        include "vars.php";
        if (getCurrentUserLevel()!=null && getCurrentUserLevel()<=0) {
            if (getParameter("mode")!=null)
            {
                $mode=getParameter("mode");
            }
        }



        //   echo $fontname.$rs->fields["font".$lt."local"].$fontlocal."ihj";

        include "lang_".$lang.".php";


        //$logo=$rs->fields["sitelogo"];
        $googleAnalytics=$rs->fields["googleAnalytics"];

        $isFree=true;
        if (($rs->fields["isFree"]=="N")) $isFree=false;

        $defaultPage=$rs->fields["defaultPage"];

        $appname="";
        $apppath="";

//echo getParameter("language")." ".getParameter("pageName")."<br/>";
        if (getParameter("pageName")!=null)
        {
            $pageName=getParameter("pageName");
            $sSql = "select * from portal_pages WHERE portalId = ".$portalId." and active='Y' and name='".$pageName."' ";
            Portal_log($sSql);
            $rs=$GLOBALS["conn"]->Execute($sSql);


        }
        else
        {
            $sSql ="select * from portal_pages WHERE portalId = ".$portalId." and active='Y' and type <> 'S' and id=$defaultPage Order By portal_pages.orderCmpnt";
            Portal_log($sSql);
            $rs=$GLOBALS["conn"]->Execute($sSql);
            $pageName=$rs->fields["name"];




        }

        $customCss=$rs->fields["customCss"];
        $customScript=$rs->fields["customScript"];
        $pagetitle=$rs->fields["title_".$LANG];
        $pageId=$rs->fields["id"];

        $layoutId=$rs->fields["layoutId"];

        if(!canView("portal_pages",$rs->fields["id"])) {
            $pageId=null;

        }


        if ($pageId=="" || $pageId==null) {
            //echo "ERROR : Page not found!";
            Dispaly_Page_Msg("ERROR : Page not found!");
            //header("Location: /"); // 404 NEEDED
            exit();
        }



//getting page layout

        $sSql ="SELECT layout.layout,layout.id FROM  portal_layout layout INNER JOIN  portal_pages pages ON pages.layoutId = layout.id WHERE layout.portalId=$portalId and  pages.name='".$pageName."' AND pages.portalId =".$portalId."";
        if (EW_DEBUG_ENABLED=="TRUE")  echo $sSql;
        $rs=$GLOBALS["conn"]->Execute($sSql);  Portal_log($sSql);
        $layout=$rs->fields["layout"];


        //get application locales
   getAppLocales();

        if ($mode=="show") {
        
        	
        	
        	$layout=getPageLayout($pageId);
            
            


            //echo $layout;
            
            
            
            /*
            //Merge Shared Block into Root Layout
             
            
            $sSql="SELECT
            portal_sharedblocks.id,
            CONCAT(\"container\",portal_sharedblock_container.place) AS place,
            portal_layout.layout
            FROM
            portal_sharedblocks
            INNER JOIN portal_sharedblock_container ON portal_sharedblocks.id = portal_sharedblock_container.sharedBlockId
            INNER JOIN portal_pages ON portal_sharedblocks.pageId = portal_pages.id
            INNER JOIN portal_layout ON portal_pages.layoutId = portal_layout.id
            WHERE portal_sharedblocks.layoutId = $layoutId";
            
            
      //    echo  $sSql."<br/>";
            $rs=$GLOBALS["conn"]->Execute($sSql);
            
            
            
            while ( !$rs->EOF)  {
            
            
            
            
            
            
            	$div="<div id=\\\"".$rs->fields["place"]."\\\" class=\\\"portalBox\\\">";
            	//$layout=str_replace($div,$div."\"; include \"apps/".$rs->fields["appurl"]."/index.php\"; echo \"",$layout); // alternative
            
            	$sharedLayout=$rs->fields["layout"];
            	 
                        	if (false) { ?>
                        	
                        	<script type="text/javascript">
            					alert('<?=$sharedLayout?>');
            				</script>
                        	<?php        
                        	}
                        	     	
                        	$sharedLayout=str_replace("\"","\\\"",$sharedLayout);
                        			
                        	$sharedLayout=str_replace("id=\\\"container","id=\\\"".$rs->fields["place"]."_container",$sharedLayout);
                        	
                                
                        	//$sharedLayout='<div id="container1" class="portalBox"></div>';
                        	$layout=str_replace($div,$div.$sharedLayout,$layout);//preg_replace($div, "SharedBlock", $layout);
                        
                        
                        
                        
                        	$rs->MoveNext();
                        }*/
            				
                        $sSql="";
        $sSql="Select portal_portlet.id as portletId,
		 portal_portletpage.orderCmpnt as portletOrder,
		 portal_portlet.appname, portal_portlet.appurl,
		 portal_portletpage.place,
		 portal_portletpage.id as instanceId
		 From portal_portletpage Inner Join 
		portal_portlet On portal_portlet.id = portal_portletpage.portletId 
		Inner Join portal_pages On portal_pages.id = portal_portletpage.pageId
		 Where portal_pages.portalId=$portalId And portal_pages.name = '$pageName' ";
            
           /* $sSql.=" Union ";
			//adding shared blocks portlets
			
            
            $sSql.="  SELECT

            portal_portletpage.portletId,
            portal_portletpage.orderCmpnt as portletOrder,
            portal_portlet.appname,
            portal_portlet.appurl,
            CONCAT('container',portal_sharedblock_container.place,'_',portal_portletpage.place) AS place,
            portal_portletpage.id as instanceId
            
            FROM
            portal_sharedblocks
            INNER JOIN portal_sharedblock_container ON portal_sharedblocks.id = portal_sharedblock_container.sharedBlockId
            INNER JOIN portal_portletpage ON portal_portletpage.pageId = portal_sharedblocks.pageId
            INNER JOIN portal_portlet ON portal_portlet.id = portal_portletpage.portletId
            WHERE portal_sharedblocks.layoutId = $layoutId";
            
         */
            
      
         
       include 'addportletinlayout.php';
           
         	
			
			

            
         //   echo "<script type=\"text/javascript\">alert('".$layout."')</script>";
        }


        //evaluate without output
        ob_start();
                                     	
                                	
        eval($layout);
        $output=ob_get_contents();
        ob_end_clean();



        ?>


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title><?php echo $pagetitle; ?></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta name="generator" content="Butterfly Portal"/>
    <meta name="author" content="Butterfly Portal INC"/>
    <meta name="description" content="<?php echo $description; ?>" />
    <meta name="keywords" content="<?php echo $keywords; ?>" />
    <meta name="robots" content="Index, Follow" />
    <meta name="title" lang="<?php echo $lang; ?>" content="<?php echo $pagetitle; ?>" />
    <meta http-equiv="content-language" content="<?php echo $lang."-".$LANG; ?>" />
    <meta name="language" content="<?php echo $lang."-".$LANG; ?>" />

    <meta property="og:title" content="<?php echo $pagetitle; ?>" />
    <meta property="og:type" content="article" />
    <meta property="og:url" content="<?php echo curPageURL(); ?>" />
    <meta property="og:image" content="<?php echo $FB_image; ?>" />
    <meta property="og:site_name" content="<?php echo getPortalName(); ?>"/>
    <meta property="og:description" content="<?php echo $FB_description; ?>" />

        <?php loadfile("/css/normalization.css","css"); ?>
        <?php loadfile("/js/jquery.min.js","js"); ?>
        <?php loadfile("/css/jquery.ui.css","css"); ?>
        <?php loadfile("/css/banner_style.css","css"); ?>
        <?php loadfile("/css/prettyGallery.css","css"); ?>
        <?php loadfile("/css/prettyPhoto.css","css"); ?>
        <?php loadfile("/css/nivo-default.css","css"); ?>
        <?php loadfile("/css/nivo-slider.css","css"); ?>
        <?php //loadfile("/css/validationEngine.jquery.css","css"); ?>
        <?php loadfile("/js/fancybox/jquery.fancybox.css","css"); ?>
        <?php loadfile("/js/jquery.jcarousel.min.js","js"); ?>
        <?php loadfile("/js/jquery.colorbox-min.js","js"); ?>
       	<?php loadfile("/css/jcarousel/skins/tango/skin.css","css"); ?>
		
		
        <?php loadfile("/js/jquery.elevateZoom-3.0.3.min.js","js"); ?>


         <?php loadfile("/js/jquery-ui-tabs-rotate.js","js"); ?>
        <?php loadfile("/js/jquery-ui.custom.min.js","js"); ?>
        <?php //loadfile("/js/jquery.tools.min.js","js"); ?>
        <?php loadfile("/js/jquery.tubeplayer.min.js","js"); ?>
        <?php //loadfile("js/jquery.validationEngine-$lang.js","js"); ?>
        <?php //loadfile("js/jquery.validationEngine.js","js"); ?>

   <script type="text/javascript"
      src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAncrbHKhsDE5ClfT-tADu2-4Fdqa9Jpq8&sensor=false">
    </script>
        <?php
// files specific to direction
        if ($dir=="ltr") {?>
            <?php } else { ?>
            <?php
            //http://api.yamli.com
            loadfile("/js/yamli_api.js","js"); ?>

            <?php }  ?>

        <?php

        //bug to fix
        if ($mode=="showx") { ?>
            <?php loadfile("/js/ui.core.js","js"); ?>
            <?php } ?>


        <?php if (false) loadfile("/js/ui.spinner.js","js"); ?>
        <?php if (false) loadfile("/js/jquery.simplemodal.1.4.1.min.js","js"); ?>

        <?php loadfile("/js/custom.js","js"); ?>

        <?php loadfile("/js/editor/tiny_mce/tiny_mce.js","js"); ?>
    <!--<?php loadfile("/js/less-1.2.1.min.js","js"); ?> -->
        <?php loadfile("/js/jquery.form.js","js"); ?>
        <?php loadfile("/js/jquery.nivo.slider.pack.js","js"); ?>
        <?php loadfile("/js/nivo.slider.link.js","js"); ?>
        <?php loadfile("/js/superfish.js","js"); ?>

        <?php loadfile("/js/fancybox/jquery.fancybox.js","js"); ?>

<script src="/js/swfobject.js" type="text/javascript"></script>  
        





    <!--
<?php loadfile("/js/nicEdit.js","js"); ?>
<?php loadfile("/js/jquery.jscrollpane.min.js","js"); ?>
<?php loadfile("/js/jcarousel.min.js","js"); ?>
<?php loadfile("/js/scripts.js","js"); ?>
<?php loadfile("/js/jquery.mousewheel.js","js"); ?>
<?php loadfile("/js/slides.min.jquery.js","js"); ?>
<?php loadfile("/js/divscroll.js","js"); ?>


<?php loadfile("/js/jquery.chrono.min_.js","js"); ?>
<?php loadfile("/js/jquery.prettyGallery.js","js"); ?>
<?php loadfile("/js/jquery.prettyPhoto.js","js"); ?>


 -->

        <?php

        // Load css and js files for inculded applications

        $sSql="SELECT
DISTINCT(portal_app.`name`) as appname
FROM
portal_portal_app
INNER JOIN portal_app ON  portal_portal_app.appId = portal_app.id
WHERE
portal_portal_app.portalId = $portalId";
        
       //  echo $sSql."<br/>";
        Portal_log($sSql);
        $rs=$GLOBALS["conn"]->Execute($sSql);

        if ($rs) {
            while ( !$rs->EOF)  {
                ?>

                <?php loadfile("/css/applications/".$rs->fields["appname"].".css","css"); ?>
                <?php loadfile("/js/applications/".$rs->fields["appname"].".js","js"); ?>
                <?php loadfile(getFilesPath("css/applications/",false).$rs->fields["appname"].".css","css"); ?>
                <?php if ($lang=="ar") {?>

                    <?php loadfile(getFilesPath("css/applications/",false).$rs->fields["appname"]."_ar.css","css"); ?>
                    <?php loadfile("/css/applications/".$rs->fields["appname"]."_ar.css","css"); ?>
                    <?php } ?>
                <?php loadfile(getFilesPath("js/applications/",false).$rs->fields["appname"].".js","js"); ?>
                <?php
                $rs->MoveNext();
            }
        }





        ?>


        <?php //End Dynamic SyleSheet ?>

        <?php loadfile("/js/jquery.blockUI.js","js"); ?>
        <?php //Dynamic Fonts

        $defaultfont="";

        $sSql ="SELECT
portal_fonts.`name` as fontName,
portal_fonts.url as fontUrl,
portal_fonts.`local` as isLocalFont
FROM
portal_portal_fonts
INNER JOIN portal_fonts ON portal_portal_fonts.fontId = portal_fonts.id
WHERE
portal_fonts.lang = '$lt' AND portal_portal_fonts.portalId=$portalId order by portal_fonts.id desc";
        Portal_log($sSql);
        if (EW_DEBUG_ENABLED=="TRUE")  echo $sSql;
        $rs=$GLOBALS["conn"]->Execute($sSql);


        while ( !$rs->EOF)  {
            $fonturl=$rs->fields["fontUrl"];
            $fontname=$rs->fields["fontName"];
            $fontlocal=true;

            if ($defaultfont=="") $defaultfont=$fontname;

            if ($rs->fields["isLocalFont"]=="N") $fontlocal=false;

            if ($fontlocal==true) {
                ?>

            <style>
                @font-face {
                    font-family: '<?php echo $fontname; ?>';
                    src: url('/fonts/<?php echo $fonturl; ?>.eot');
                    src: url('/fonts/<?php echo $fonturl; ?>.eot?#iefix') format('embedded-opentype'),
                    url('/fonts/<?php echo $fonturl; ?>.woff') format('woff'),
                    url('/fonts/<?php echo $fonturl; ?>.ttf') format('truetype'),
                    url('/fonts/<?php echo $fonturl; ?>.svgz#<?php echo $fontname; ?>') format('svg'),
                    url('/fonts/<?php echo $fonturl; ?>.svg#<?php echo $fontname; ?>') format('svg');
                    font-weight: normal;
                    font-style: normal;

                }

            </style>


                <?php
            }else{
                if (true) { ?>

                    <?php loadfile("http://fonts.googleapis.com/css?family=$fonturl","css"); ?>

                    <?php }else{ ?>
                <script src="https://www.google.com/jsapi"> </script>
                <script type="text/javascript">
                    google.load("webfont", "1");

                    google.setOnLoadCallback(function() {
                        WebFont.load({
                            google: {
                                families: [ '<?php echo $fonturl; ?>' ]
                            }});
                    });
                </script>
                    <?php
                }}
            $rs->MoveNext();
        }

        // end Dynamic Fonts
        ?>


        <?php

        $file="/css/vars.css";


        $sSql="SELECT * FROM portal where id= $portalId";
        $rs=$GLOBALS["conn"]->Execute($sSql);



//echo $sSql."<br/>";


// Add more elements as you want
        if (!$rs->EOF){

     

        ?>
        
        <style type="text/css">
        
        
        body {
        
          font-family: <?=$defaultfont?>;  

background: url('<?=getFileManagerImage('image',$rs->fields["background_file"])?>') <?=$rs->fields["repeatBackground"]?> scroll center top #FFFFFF ;
}
a{
color: <?=$rs->fields["OneColor"]?>;
}
input{
font-family: <?=$defaultfont?>;
}

select{
font-family: <?=$defaultfont?>;
    }
textarea{
font-family: <?=$defaultfont?>;
    }

        </style>
<?php } ?>

<?php 

//load custompage css
$path=getFilesPath("css")."/".$pageName.".css";
if (file_exists($path)) Loadfile($path, "css");

?>


        <?php //End Dynamic Fonts ?>

    <script type="text/javascript">

        function logout()
        {
            // $.blockUI({ message: '<div class="loading"><img src="/images/busy.gif" /> Just a moment...</div>' });
            <?php blockUI($var_portal_loggingout); ?>
            $.get("/butterflyportal/?action=logout", function(data){


                location.href="/";

            });
        }

    </script>
        <?php if (getCurrentUserLevel()!=null &&  getCurrentUserLevel()<0) { ?>

        <?php loadfile("/css/system.css","css"); ?>
        <?php if ($mode=="edit") { ?>

            <?php loadfile("/css/portal_system.css","css"); ?>

            <?php loadfile("/js/jquery.portal.js","js"); ?>

        <link href='http://fonts.googleapis.com/css?family=Imprima' rel='stylesheet' type='text/css'>

        <script type="text/javascript">


            function edit_rights()
            {

                $.get("/portlet.php",
                        {app: "system_editrights",
                            objectId:<?php echo $pageId; ?>},
                        function(data){

                            $("#ajaxdialog").html(data);
                            $("#ajaxdialog").dialog({
                                autoOpen: true,
                                height: 600,
                                width: 800,
                                modal: true,
                                zIndex: 3999,
                                buttons: {
                                    "Save": function() {
                                        alert("ok");
                                    },
                                    Cancel: function() {
                                        $( this ).dialog( "close" );
                                    }
                                }


                            });


                        });
            }
        </script>
            <?php } ?>

        <?php } ?>

        <?php loadfile(str_replace("..", "", $customCss),"css"); ?>
        <?php loadfile(str_replace("..", "", $customScript),"js"); ?>




    </head>

    <body dir="<?php echo $dir; ?>">
    <div id="fb-root"></div>
    <script>(function(d, s, id) {
        var js, fjs = d.getElementsByTagName(s)[0];
        if (d.getElementById(id)) return;
        js = d.createElement(s); js.id = id;
        js.src = "//connect.facebook.net/<?=$lang?>_<?=$LANG?>/all.js#xfbml=1";
        fjs.parentNode.insertBefore(js, fjs);
    }(document, 'script', 'facebook-jssdk'));</script>



        <?php




        if ($show_controls && getCurrentUserLevel()!=null &&  getCurrentUserLevel()<0) {?>

        <div id="Admin_bar">

            <img class="edit_portal" src="<?php if ($mode=="edit") echo "/images/icons/close.png"; else echo "/images/icons/edit.png"; ?>" onclick="toogle_edit()">
            <?php if ($mode=="edit") { ?><img class="edit_portal" src="/butterflyportal/images/menu/portlets.png" onclick="toogle_portlets()"><?php } ?>
            <img class="edit_portal" src="/images/icons/editrights.png" onclick="edit_rights()">
            <img class="edit_portal" src="/butterflyportal/images/menu/logout.png" onclick="logout()">
            <a href="/butterflyportal/portal_pagesedit.php?id=<?php echo $pageId; ?>" target="_self"><img class="edit_portal" src="/butterflyportal/images/menu/portal_pages.png" alt="Edit PÃƒÂ¤ge"></a>
            <a href="/butterflyportal/portal_layoutedit.php?id=<?php echo $layoutId; ?>" target="_self"><img class="edit_portal" src="/butterflyportal/images/menu/portal_layout.png" alt="Edit Layout"></a>

            <a style="float: right;padding-right: 6px;" href="/butterflyportal/" target="_blank"><img class="edit_portal" src="/butterflyportal/images/menu/portal.png" alt="Edit Layout"></a>
        </div>


        <div style="height: 30px;"></div>
        <div id="ajaxdialog"></div>
            <?php } ?>

    <form action="<?php echo curPageURI();?>" id="pageForm" method="post"> </form>
    <script type="text/javascript">

    function toogle_portlets()
    {
$("#portlets_list").toggle();
        }
        function sendByPost(names,values)
        { for (var i=0;i<names.length;i++) {
            $("#pageForm").append("<input type=\"hidden\" name=\""+names[i]+"\" value=\""+values[i]+"\"/>"); }
            $("#pageForm").submit();
        }
        function toogle_edit()
        {
            <?php
            if ($mode!="edit") {  ?>
                location.href="<?php echo createUrl("pageName",getParameter("pageName"),"mode","edit"); ?>";
                <?php } else { ?>
//ok
                location.href="<?php echo createUrl("pageName",getParameter("pageName"),"mode","show"); ?>";
                <?php }  ?>
        }


    </script>



        <?php if ($mode=="edit") {
    include "editmode.php";

            }



        //print processed page

        if ($mode=="show") echo $output; //eval($layout);


        if ($isFree){
            ?>
      

            <?php  }?>

        <?php  if (!isLocal()) { ?>
    <script type="text/javascript" >
        var _gaq = _gaq || [];
        _gaq.push(['_setAccount', '<?php echo $googleAnalytics; ?>']);
        // _gaq.push(['_setDomainName', '<?php echo $_SERVER['HTTP_HOST']; ?>']);
        _gaq.push(['_trackPageview']);

        (function() {
            var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
            ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
            var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
        })();

    </script>
        <?php } ?>
        <?php $GLOBALS["gsTimer"]->Stop(); ?>





        <?php  if ($show_controls) { ?>
    <div style="text-align:center; font-size: 12px;" class="poweredby"> <?php echo "Made with Butterfly Portal in ".getExecutionTime()." seconds";?> </div>
    <?php } ?>


    </body>



    </html>

    <?php

    }
}

else{

    Dispaly_Page_Msg("<img src='images/portalnotfound.png'/>");

}




?>
